package com.woniuxy.background.service.impl;

import com.woniuxy.background.dao.AdminMapper;
import com.woniuxy.background.pojo.Admin;
import com.woniuxy.background.service.AdminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class AdminServiceImpl implements AdminService {

    @Autowired
    private AdminMapper adminMapper;

    @Override
    public Admin findAdmin(Admin admin) {
        Admin loginAdmin  = adminMapper.findByName(admin.getUsername());
        if(loginAdmin.getPassword().equals(admin.getPassword())){
            return loginAdmin;
        }
        return null;
    }

    @Override
    public List<Admin> adminList() {
        return adminMapper.adminList();
    }

    @Override
    public int deleteByPrimaryKey(Integer adminId) {
        return adminMapper.deleteByPrimaryKey(adminId);
    }

    @Override
    public int insert(Admin record) {
        return adminMapper.insert(record);
    }

    @Override
    public Admin selectByPrimaryKey(Integer adminId) {
        return adminMapper.selectByPrimaryKey(adminId);
    }

    @Override
    public int updateByPrimaryKeySelective(Admin record) {
        return adminMapper.updateByPrimaryKeySelective(record);
    }

    @Override
    public Admin selectAdminByName(Admin admin) {
        return adminMapper.findByName(admin.getUsername());
    }

    @Override
    public List<Admin> selectAdminByRoleId(int roleId) {
        return adminMapper.selectAdminByRoleId(roleId);
    }
}
